home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9608 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  54 lines

  1. Path: library.erc.clarkson.edu!koglerje
  2. From: koglerje@craft.camp.clarkson.edu (Mountain (jimbo) )
  3. Newsgroups: comp.lang.c
  4. Subject: Re: ?? How to dump text files to screen ??
  5. Date: 12 Mar 1996 03:10:25 GMT
  6. Organization: Clarkson University
  7. Message-ID: <4i2pv1$it4@library.erc.clarkson.edu>
  8. References: <31430CE8.469E@aol2.com>
  9. NNTP-Posting-Host: fire.camp.clarkson.edu
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Neil (neil@aol2.com) wrote:
  13. : I need help -- how can I open up a text file and just dump it
  14. : all out (in plain text) to the screen?
  15.  
  16. : Please post solution or mailto:neil@aol2.com
  17.  
  18. : Thanks!
  19. : Neil Mansilla
  20.  
  21. Open a the file, then read in charters until the end, echo the charaters
  22. to the screen. done like so:
  23. ----
  24. include <stdio.h>
  25. main()
  26. {
  27.  FILE *fptr;
  28.  char ch;
  29.  
  30.  fptr = fopen("YOUR FILE NAME AND PATH","+r");
  31.  if (fptr == NULL)
  32.    {printf("\nERROR, NO FILE FOUND\n");
  33.    return(-1);
  34.    }
  35.  while (ch != EOF)
  36.    { ch=fgetch(fptr);
  37.      fputch(stderr,ch);
  38.    }
  39. }
  40. ----
  41. Ok, if i didn't make stupid mistakes then thats it, check and see if its putch
  42. or puts that you want to use.
  43.  
  44. good luck 
  45. jimbo
  46.  
  47.  
  48. _________________________________________________________________
  49. Jim Kogler                           | To Error is Human,
  50. mountain@wckn.dorm.clarkson.edu      | To Debug, Devine.
  51. koglerje@wckn.dorm.clarkson.edu      |
  52. http://fire.clarkson.edu/~koglerje/  |
  53.  
  54.